home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
GRAPHICS
/
TS32
/
DIBDRAWI.INT
< prev
next >
Wrap
Text File
|
1996-03-21
|
7KB
|
200 lines
unit DIBDrawingSurface;
(*********************************************
TDIBDrawingSurface -> TGraphicControl
Provides an interface to a Windows DIB drawing surface
implemented through calls to WING32.DLL.
Properties
AutoBlank-
Set to TRUE and the DIB data will be filled with the
AutoBlankColor during each call to DIBRefresh.
AutoBlankColor-
The color index that will be used to fill the DIB
if AutoBlank is TRUE.
BackgroundDIB-
Point to a TDIB on the form if you want a background
image to be rendered during each call to DIBRefresh.
BitmapInfo-
The TBitmapInfo structure for the DIB surface.
ColorPalette-
Point this to a TColorPalette on the form to use that
palette. If nil, whatever happens to be in the current
logical palette will be used.
DIBCanvas-
A TDIBCanvas that manages the DIB surface's properties.
You can control the underlying behavior of the control
by modifying properties at design time, such as Width,
Height and Orientation. Access to the DIB surface's
memory is through this object's Bits property.
DirtyRectangle-
Set this to TRUE if the corresponding DirtyRectangle
property of a TSpriteEngine is TRUE also. It causes the
background of the surface to totally render ONLY when the
Force flag is TRUE.
FillSurface-
Fill the surface with the specified color.
ForceRefresh-
Set this to TRUE when the entire surface must be rendered
from scratch. This is automatically set to TRUE during the
paint method. It is set to FALSE at the end of each call
to DIBRefresh.
GDICanvas-
The GDI canvas associated with this DIB surface. GDI
calls can be made using the handle of this Canvas, but
if this is to be done, be sure to call SelectPalette
and RealizePalette for proper color rendering.
OffsetX,OffsetY-
The offset of the control's logical coordinate system.
All sprite positions are based on the logical coord system.
Palette-
The logical palette being used by this DIB.
PaletteEntryFlag-
Reccommned to leave at pcNoCollapse.
PhysicalWidth,PhysicalHeight-
Return the dimensions of the underling DIBCanvas.
WrapHorizontal,WrapVertical
Controls whether sprites wrap around when they leave the
edge of the area.
Events
OnCustomPaint-
Gets triggered after the rendering of the background
but before the surface is actually blitted to the screen.
This is the hook where the sprite engine processing
should occur.
Methods
DIBRefresh-
Call this to blast the DIB data to the screen. Usually
this call is placed in a HiResTimer event.
*********************************************)
interface
uses
Windows, SysUtils, Messages, Classes, Graphics, Controls,
Forms, Dialogs, DIB, ExtCtrls, Grafix, ColorPalette,
DIBCanvas, DsgnIntf, ColorIndexEditor;
type
TDIBDrawingSurface = class;
(***************************************************
This record represents a TBitmapInfo record with a
256 color palette
***************************************************)
TBM = record
bminfo: TBitmapInfo;
bmiColors: array[1..256] of TRGBQuad;
end;
TPaletteEntryFlag = ( pcNoCollapse, pcReserved );
EDIBDrawingSurface = class( Exception );
TDIBDrawingCanvas = class( TDIBCanvas )
private
dds: TDIBDrawingSurface;
protected
procedure SetWidth( n: integer ); override;
procedure SetHeight( n: integer ); override;
public
published
end;
TDIBDrawingSurface = class( TGraphicControl )
private
nDummy: integer;
FDIBCanvas: TDIBDrawingCanvas;
procedure CreateDIBBitmap;
procedure SetCoords( X, Y: integer );
procedure SetBoundsRect;
protected
bCreated: boolean; { Has the WinGBitmap been created? }
bm: TBM; { 256 color TBitmapInfo record }
dcWindow: HDC;
FAuto: boolean;
FAutoColor: byte;
FBackDIB: TDIB;
FFlag: TPaletteEntryFlag;
FFlag_: byte;
FColorPalette: TColorPalette;
FOffX, FOffY: integer;
FWrapHorz, FWrapVert: boolean;
hDIBBitmap: HBitmap;
hDIBDC: HDC; { WinG device context }
hLogPalette: HPalette; { Logical palette }
hOldBitmap: HBitmap;
hwndParent: HWND;
nWidth, nHeight: integer;
nSize: integer;
pbminfo: PBitmapInfo; { Points to the bm record }
ppal: PLogPalette; { Pointer to logical palette }
pSurfaceBits: pointer; { Access to Pixels as pointer }
rectBounds: TRect;
X_, Y_: integer; { Store the translated mouse coords }
FCanvas: TCanvas;
FPhysicalWidth, FPhysicalHeight: integer;
FOnCustomPaint: TNotifyEvent;
FForce: boolean;
FDirty: boolean;
procedure CreateDIBPalette;
procedure CreateIdentPalette;
function GetBitmapInfo: TBitmapInfo;
function GetCanvas: TCanvas;
procedure PaintHook1; dynamic;
procedure SetDIBCanvas( dc: TDIBDrawingCanvas );
procedure SetBounds( ALeft, ATop, AWidth, AHeight: Integer ); override;
procedure SetFlag( f: TPaletteEntryFlag );
procedure SetBackDIB( dib: TDIB );
procedure MouseMove( Shift: TShiftState; X, Y: integer ); override;
procedure MouseDown( Button: TMouseButton; Shift: TShiftState; X, Y: integer ); override;
procedure MouseUp( Button: TMouseButton; Shift: TShiftState; X, Y: integer ); override;
procedure Notification( AComponent: TComponent; Operation: TOperation ); override;
procedure Paint; override;
public
constructor Create( AOwner: TComponent ); override;
destructor Destroy; override;
procedure DIBRefresh;
procedure FillSurface( n: byte );
procedure RenderBackgroundDIB( dib: TDIB );
property BitmapInfo: TBitmapInfo read GetBitmapInfo;
property GDICanvas: TCanvas read FCanvas;
property ForceRefresh: boolean read FForce write FForce;
property Palette: HPalette read hLogPalette;
property PhysicalWidth: integer read FPhysicalWidth;
property PhysicalHeight: integer read FPhysicalHeight;
published
property AutoBlank: boolean read FAuto write FAuto;
property AutoBlankColor: byte read FAutoColor write FAutoColor;
property BackgroundDIB: TDIB read FBackDIB write SetBackDIB;
property DirtyRectangle: boolean read FDirty write FDirty;
property OffsetX: integer read FOffX write FOffX;
property OffsetY: integer read FOffY write FOffY;
property OnClick;
property OnDblClick;
property OnMouseMove;
property OnMouseDown;
property OnMouseUp;
property ColorPalette: TColorPalette read FColorPalette write FColorPalette;
property DIBCanvas: TDIBDrawingCanvas read FDIBCanvas write SetDIBCanvas;
property PaletteEntryFlag: TPaletteEntryFlag read FFlag write SetFlag;
property WrapHorizontal: boolean read FWrapHorz write FWrapHorz;
property WrapVertical: boolean read FWrapVert write FWrapVert;
property OnCustomPaint: TNotifyEvent read FOnCustomPaint write FOnCustomPaint;
end;
TColorIndexEditor = class( TIntegerProperty )
private
protected
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
procedure Register;